<?php 
    //$data = array('name'=>'boynew', "upload"=>"@D:\myphp_www\PHPTutorial\WWW\gitTest\curl_learning\boy.jpg");
	$file = file_get_contents('http://192.168.1.139/gitTest/abc.jpg');
	$data = array('name'=>'boynew', "upload"=>"@".$file);
	//设置响应头(编码格式)
	header("Content-Type:text/html;charset=utf-8");
    $ch = curl_init(); 
	// php5.3
    curl_setopt($ch, CURLOPT_URL, "http://192.168.1.139/gitTest/curl_learning/testRespond.php"); 
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); 
    curl_setopt($ch, CURLOPT_POSTFIELDS , $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
 
    $output = curl_exec($ch); 
	
	//curl_getinfo()获取各种运行中信息，便于调试 
	$info = curl_getinfo($ch);
	 
	echo "执行时间".$info['total_time'].PHP_EOL;

    echo $output;
 
    curl_close($ch);         
	
	// php5.6

    // $data['upload']=new CURLFile(realpath(getcwd().'/boy.png'));
    // curl_setopt($ch, CURLOPT_URL, "http://192.168.1.185/curl_learning/testRespond.php"); 
    // curl_setopt($ch, CURLOPT_POST, 1);
    // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); 
    // curl_setopt($ch, CURLOPT_POSTFIELDS , $data);
    // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
 
    // $output = curl_exec($ch); 
 
    // echo $output;
 
    // curl_close($ch);  
?>